<?xml version="1.0" encoding="UTF-8"?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	template="/WEB-INF/templates/template.xhtml"
	xmlns:a4j="http://richfaces.org/a4j"
	xmlns:rich="http://richfaces.org/rich"
	>
	<ui:define name="content">
	
		<ui:include src="/includes/menu.xhtml"></ui:include>
		
		
		<a4j:outputPanel id="fragmentpanel" layout="block">
              <rich:panel style="float:left; width:800px; padding:5px;">
				<h1><h:outputText value="#{fragmentBean.fragment.title}" /></h1>
				<h:outputText value="#{fragmentBean.fragment.description}"/> <br />
			
				<h2><h:outputText value="Contents of Fragment" /></h2>
		
				<a4j:outputPanel id="panel" layout="block">
		          <a4j:repeat value="#{fragmentBean.content}" var="content" rows="20" id="repeat">
		              <rich:panel style="float:left; width:750px; padding:5px;">
		                  <f:facet name="header">
		                      <h:panelGroup>
		                       	<h:panelGrid columns="2">
			                       	<h:link includeViewParams="true" outcome="content">
							    		<f:param name="content" value="#{content.id}"/>
			                       	   	<h:outputText value="#{content.date} : " />
			                          	<h:outputText value="#{content.content} " />
			                        </h:link>
		                  		</h:panelGrid>
		                      </h:panelGroup>
		                  </f:facet>
		                  <h:panelGrid columns="1" style="float:right;" rendered="#{fragmentBean.admin}">
		                      <h:form>
								<h:commandButton value="delete" action="#{fragmentBean.deleteContent(content.id)}" />
							  </h:form>
		                  </h:panelGrid>
		              </rich:panel>
		          </a4j:repeat>
		       </a4j:outputPanel>
			</rich:panel>
    	</a4j:outputPanel>
		
		<a4j:outputPanel id="addContentPanel" layout="block">
			<rich:panel style="float:left; width:800px; padding:5px;">
			<h:form id="addContent" rendered="#{fragmentBean.admin}">
				<h:panelGrid columns="2">
					<h:outputText value="Typ obsahu" />
					<h:inputText value="#{fragmentBean.contentType}" />
					<h:outputText value="Obsah" />
					<h:inputTextarea value="#{fragmentBean.contentContent}" />
				</h:panelGrid>
				<h:commandButton value="Vytvoř obsah" action="#{fragmentBean.addNewContent(fragmentBean.fragment.id)}" />
			</h:form>
			</rich:panel>
		</a4j:outputPanel>
	</ui:define>
</ui:composition>